const app = getApp();
Page({

  /**
   * 页面的初始数据
   */
  data: {
    qrcode: '',
    key: '',
    username: ''
  },

  onLoad: function () {
    var self = this;
    wx.getStorage({
      key: 'username',
      success: (res) => {
        self.setData({
          'username': res.data,
        });
      }
    })
    wx.getStorage({
      key: 'key',
      success: (res) => {
        self.setData({
          'key': res.data,
        });
        self.getInfo(res.data);
      }
    })
  },
  getInfo: function (key) {
    var self = this;
    wx.request({
      url: app.globalData.ApiUrl + '/index.php?act=wx_qrcode&op=index',
      data: {
        key: key,
      },
      method: 'POST',
      header: {
        'content-type': 'application/x-www-form-urlencoded'
      },
      dataType: 'json',
      success: (res) => {
        if (res.data.code == 200) {
          self.setData({
            qrcode: res.data.datas
          })
        } else {
          wx.showToast({
            title: res.data.datas.error,
            icon: 'none'
          })
        }
      }
    });
  }

})